package com.example.mapper;

import com.example.pojo.TileReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TileReqMapper {
    @Select("SELECT ST_AsMVT(mvt, 'polygons') mvt FROM(\n" +
            "SELECT ST_AsMVTGeom(w.geom,ST_MakeEnvelope ( #{v}, #{v1}, #{v2}, #{v3}, 4326 ), 4096, 512, true)\n" +
            "AS geom FROM 建筑 w) AS mvt WHERE mvt.geom is not null")
//    @Select("WITH mvtgeom AS(SELECT ST_AsMVTGeom(t.geom,ST_MakeEnvelope(#{v}, #{v1}, #{v2}, #{v3}, 4326),4096,0,true) " +
//            "AS geom FROM 建筑 t where t.geom IS NOT NULL AND ST_Intersects(geom, ST_MakeEnvelope(#{v}, #{v1}, #{v2}, #{v3}, 4326))) " +
//            "SELECT ST_AsMVT(mvtgeom.*,'polygons') mvt FROM mvtgeom ;")
    List<TileReq> getTileReqStream(@Param("v") double v, @Param("v1")double v1, @Param("v2")double v2, @Param("v3")double v3);
}
